include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=hlg-gpio-ctrl
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_LICENSE:=GPL-1.0

include $(INCLUDE_DIR)/package.mk

define KernelPackage/hlg-gpio-ctrl
	SUBMENU:=Other modules
	TITLE:=4G power ctrl driver
	DEPENDS:=@TARGET_ramips_mt7621
	FILES:=$(PKG_BUILD_DIR)/*.ko
	AUTOLOAD:=$(call AutoLoad,30,gpio-ctrl-4g gpio-ctrl-5g gpio-ctrl-bridge gpio-ctrl-mesh,1)
	KCONFIG:=
endef

define KernelPackage/hlg-gpio-ctrl/description
	Kernel module to control GPIO LED for mt7621
endef

#MAKE_OPTS:= \
	$(KERNEL_MAKE_FLAGS) \
	SUBDIRS="$(PKG_BUILD_DIR)"

#define Build/Compile
#	$(MAKE) -C "$(LINUX_DIR)" \
		$(MAKE_OPTS) \
		modules
#endef




define Build/Compile
	$(MAKE) -C "$(LINUX_DIR)" \
		ARCH="$(LINUX_KARCH)" \
		CROSS_COMPILE="$(TARGET_CROSS)" \
		M="$(PKG_BUILD_DIR)" \
		modules
endef

define KernelPackage/hlg-gpio-ctrl/install
	$(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION)
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/*.ko $(1)/lib/modules/$(LINUX_VERSION)/
endef

$(eval $(call KernelPackage,hlg-gpio-ctrl))
